n=input().split()
x=len(n)
if x<=2:
    print("wrong input")
else:
    c=[]
    for i in n:
        if i=="one":
            c.append('1')
        if i=="two":
            c.append('2')
        if i=="three":
            c.append('3')
        if i=="four":
            c.append('4')
        if i=="five":
            c.append('5')
        if i=="six":
            c.append('6')
        if i=="seven":
            c.append('7')
        if i=="eight":
            c.append('8')
        if i=="nine":
            c.append('9')
        if i=="ziro":
            c.append('0')
    v="".join(c)
    z=int(v)

    def isSimple(n):
        for i in range(100, n//2):
            if n % i == 0:
                return False
        return True
    def getNextS(n):
        if isSimple(n):
            return n
        return getNextS(n+1)
    def getBeforeS(n):
        if isSimple(n):
            return n
        return getBeforeS(n-1)
    a = getBeforeS(z)
    b = getNextS(z)



    if abs(a-z)<abs(b-z):
        print(a)
    else:
        print(b)
